package cate.game.activity.taskactivity;

import cate.common.table.activity.taskactivity.row.TaskActivityBaseRow;
import cate.game.activity.base.core.RoleActivitySingle;
import cate.game.activity.taskactivity.msg.TaskActivityResp;
import cate.game.role.Role;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteField;

public class RoleTaskActivity extends RoleActivitySingle {
    @NoteField("任务")
    public RoleTaskActivityTask task;

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        if(task == null){
            task = new RoleTaskActivityTask();
        }
        task.initialize(this);
    }

    @Override
    public void onEnter(){
        super.onEnter();
        task.onEnter();
    }

    public void noticeUpdate() {
        role.sendNow(new TaskActivityResp(this));
    }

    @Override
    public void excelCheck() {
        task.excelCheck();
    }

    @JsonIgnore
    public TaskActivityBaseRow getRow(){
        return getRole().getGame().table.taskActivity.base.get(base.configTid);
    }

    @Override
    public void onDaySpan(boolean silence){
        super.onDaySpan(silence);
        task.onDaySpanSafe(silence);
    }

    @Override
    public void onRoleOpen() {

    }

    @Override
    public void onRoleEnd() {
        task.beforeOver();
        task.clear();
    }

    @Override
    public void initSend() {
        noticeUpdate();
    }
}
